Skip to content

Conversation

@TheMeinerLP
Copy link
Contributor

@TheMeinerLP TheMeinerLP commented Nov 3, 2025

Proposed changes

We added a status code check and also a retry config to improve stability.

Fixes #196

Types of changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before
merging your code.

  • I have read the CONTRIBUTING.md
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you
did and what alternatives you considered, etc...

@TheMeinerLP TheMeinerLP requested a review from a team as a code owner November 3, 2025 08:47
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Unit Test Results

10 tests   10 ✅  1s ⏱️
 3 suites   0 💤
 3 files     0 ❌

Results for commit fc004dc.

♻️ This comment has been updated with latest results.

@TheMeinerLP TheMeinerLP requested a review from Copilot November 4, 2025 19:57
Copy link
Contributor

@theEvilReaper theEvilReaper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small thing from my side

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds retry logic and configurable interval for the update check service. The changes introduce a retry mechanism that stops checking for updates after a maximum number of failed attempts and makes the update check interval configurable via system properties.

  • Adds configurable update check interval via system property ARCR_UPDATE_SERVICE_SCHEDULE
  • Implements retry count mechanism with configurable max retries via system property ARCR_UPDATE_SERVICE_MAX_RETRY
  • Adds HTTP status code validation to detect and count failed update checks
Comments suppressed due to low confidence (1)

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/UpdateService.java:106

  • When an IOException or InterruptedException occurs, the retry count is not incremented, but it is incremented for non-200 status codes. This inconsistency means network failures (exceptions) don't count toward the max retry limit, while HTTP errors do. Consider incrementing retryCount++ in the catch block to ensure all failures are counted consistently.
        } catch (IOException | InterruptedException e) {
            LOGGER.error("Something went wrong to check updates", e);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (retryCount >= MAX_RETRY_COUNT) {
LOGGER.error("Max retry count reached for update check, stopping further attempts");
LOGGER.error("Please check your internet connection or https://hangar.papermc.io/ status.");

Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return when max retry count is reached prevents the scheduled task from continuing. However, the task will continue to run on its schedule even after max retries are reached, causing this code block to execute repeatedly. Consider canceling the scheduler when max retries are reached using this.scheduler.cancel() to prevent unnecessary repeated checks.

Suggested change
if (this.scheduler != null) {
this.scheduler.cancel();
}

Copilot uses AI. Check for mistakes.
private final SchedulerService schedulerService;
private Version remoteVersion;
private ScheduledTask scheduler;
private int retryCount = 0;
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retryCount field is accessed from the asynchronous scheduled task without synchronization. Multiple scheduled tasks could potentially execute concurrently, leading to race conditions when reading and incrementing retryCount. Consider using AtomicInteger instead of int for thread-safe operations.

Copilot uses AI. Check for mistakes.
LOGGER.error("Failed to check for updates, status code: {}", httpResponse.statusCode());
retryCount++;
return null;
}
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successful update checks (status code 200) that don't find a newer version don't reset the retry count. This means if the service experiences 4 failures followed by repeated successful checks that find no updates, it will stop working after one more failure. Consider resetting retryCount = 0 when a successful response is received (status code 200) to reset the failure counter.

Suggested change
}
}
retryCount = 0;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async UpdateService exception: UnexpectedCharacterException when parsing version

3 participants